]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
main: Use mallinfo2 when available at build time
authorRobert Mader <robert.mader@posteo.de>
Wed, 31 Mar 2021 23:08:12 +0000 (01:08 +0200)
committerMarge Bot <marge-bot@gnome.org>
Wed, 7 Jul 2021 14:44:30 +0000 (14:44 +0000)
`mallinfo` has been deprecated in favor of `mallinfo2`:
```
The fields of the mallinfo structure that is returned by the
older mallinfo() function are typed as int.  However, because
some internal bookkeeping values may be of type long, the
reported values may wrap around zero and thus be inaccurate.
```

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1786>

config.h.meson
meson.build
src/main.c
src/shell-global.c

index 141b2240a82f69d822de08349f587d2c85e9a4f9..b93fda87278b03d0fa58e8ca171c9324bc704994 100644 (file)
@@ -13,6 +13,9 @@
 /* Define to 1 if you have the `mallinfo' function. */
 #mesondefine HAVE_MALLINFO
 
+/* Define to 1 if you have the `mallinfo2' function. */
+#mesondefine HAVE_MALLINFO2
+
 /* Define to 1 fi you have the <sys/resource.h> header file. */
 #mesondefine HAVE_SYS_RESOURCE_H
 
index c642a95e93c6bd5ee549fc7611f6bec4fb711477..f0a2b4c5521f58f61a8643a472eea791910e3350 100644 (file)
@@ -158,6 +158,7 @@ cdata.set('HAVE_GIO_DESKTOP_LAUNCH_URIS_WITH_FDS',
 )
 cdata.set('HAVE_FDWALK', cc.has_function('fdwalk'))
 cdata.set('HAVE_MALLINFO', cc.has_function('mallinfo'))
+cdata.set('HAVE_MALLINFO2', cc.has_function('mallinfo2'))
 cdata.set('HAVE_SYS_RESOURCE_H', cc.has_header('sys/resource.h'))
 cdata.set('HAVE__NL_TIME_FIRST_WEEKDAY',
   cc.has_header_symbol('langinfo.h', '_NL_TIME_FIRST_WEEKDAY')
index 23944351b44a6759b6153c62fc5599edb2ebc51a..a47154db177a41a774d780501e51a93fda9950f0 100644 (file)
@@ -2,7 +2,7 @@
 
 #include "config.h"
 
-#ifdef HAVE_MALLINFO
+#if defined (HAVE_MALLINFO) || defined (HAVE_MALLINFO2)
 #include <malloc.h>
 #endif
 #include <stdlib.h>
@@ -212,8 +212,12 @@ static void
 malloc_statistics_callback (ShellPerfLog *perf_log,
                             gpointer      data)
 {
-#ifdef HAVE_MALLINFO
+#if defined (HAVE_MALLINFO) || defined (HAVE_MALLINFO2)
+#ifdef HAVE_MALLINFO2
+  struct mallinfo2 info = mallinfo2 ();
+#else
   struct mallinfo info = mallinfo ();
+#endif
 
   shell_perf_log_update_statistic_i (perf_log,
                                      "malloc.arenaSize",
@@ -224,7 +228,7 @@ malloc_statistics_callback (ShellPerfLog *perf_log,
   shell_perf_log_update_statistic_i (perf_log,
                                      "malloc.usedSize",
                                      info.uordblks);
-#endif
+#endif /* defined (HAVE_MALLINFO) || defined (HAVE_MALLINFO2) */
 }
 
 static void
index eff53f396a911292c73c9f03d492a3df66d8f2d0..99d2ac0ca617517259c102fc5a26113a0b368e56 100644 (file)
 #define GNOME_DESKTOP_USE_UNSTABLE_API
 #include <libgnome-desktop/gnome-systemd.h>
 
-/* Memory report bits */
-#ifdef HAVE_MALLINFO
-#include <malloc.h>
-#endif
-
 #if defined __OpenBSD__ || defined __FreeBSD__
 #include <sys/sysctl.h>
 #endif